﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="reg.aspx.cs" Inherits="reg" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>会员注册</title>
    <link type="text/css" href="css/other.css" rel="stylesheet" />
    <script language="javascript" type="text/javascript">
        var checkemailflag = 1; //没注册
        function checkemail(value) {
            if (value != null && value != '') {
                if (value.length < 3) {
                    checkemailflag = 0;
                    alert('邮箱不能为空!');
                    return false;
                } else if (value.length > 30) {
                    alert('邮箱过长!');
                    checkemailflag = 0;
                    return false;
                } else {
                    if (value == "请输入邮箱地址") {
                        alert('邮箱不能为空!');
                        return false;
                    }
                    if (!EmailValidate(value)) {
                        checkemailflag = 0;
                        alert('邮箱格式不正确!');
                        return false;
                    }
                    jQuery.ajax({
                        url: "Ajax/MemberLogin.ashx",
                        data: { t: 'MailCheck', txtemail: value },
                        type: "POST",
                        async: false,
                        success: function (data) {
                            if (data + '' == 'True' || data + '' == 'true') {
                                checkemailflag = 1;
                                return true;
                            } else {
                                checkemailflag = 0;
                                return false;
                            }
                        }
                    });
                }
            }
            return true;
        }
        var checkeusernameflag = 1; //没注册
        function checkusername(value) {
            if (value != null && value != '') {
                jQuery.ajax({
                    url: "Ajax/MemberLogin.ashx",
                    data: { t: 'NicknameCheck', txtnickname: value },
                    type: "POST",
                    async: false,
                    success: function (data) {
                        if (data + '' == 'True' || data + '' == 'true') {
                            checkeusernameflag = 1;
                            return true;
                        } else {
                            checkeusernameflag = 0;
                            return false;
                        }
                    }
                });
            }
            return true;
        }
        function checkmobileReg() {
            if (jQuery('#mobileReg').val().length != 11) {
                document.getElementById('mobileRegp').className = "important";
                jQuery("#mobileRegSpan").html('必须输入有效手机号');
                return;
            } else {
                document.getElementById('mobileRegp').className = "";
                jQuery("#mobileRegSpan").html('&nbsp;');
            }
        }
        function mobileusernameReg() { 
            if (jQuery('#mobileusername').val() == "") {
                document.getElementById('mobileusername').value = "请避免使用真实姓名，注册成功后不可修改";
                document.getElementById('mobileuserp').className = "important";
                jQuery("#mobileuserspan").html('请输入用户名');
                return;
            } else if (jQuery('#mobileusername').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('mobileuserp').className = "important";
                jQuery("#mobileuserspan").html('请输入用户名');
                return;
            } else if (jQuery('#mobileusername').val().length < 2) {
                document.getElementById('mobileuserp').className = "important";
                jQuery("#mobileuserspan").html('请输入用户名');
                return;
            } else {
                document.getElementById('mobileuserp').className = "";
                jQuery("#mobileuserspan").html('&nbsp;');
            }
        }
        function checkmobilePass() {
            if (jQuery('#mobilepass').val().length < 7) {
                document.getElementById('mobilpass1').className = "p_red";
                jQuery("#mobilpassspan").html('弱');
                return;
            } else if (jQuery('#mobilepass').val().length < 13) {
                document.getElementById('mobilpass2').className = "p_red";
                jQuery("#mobilpassspan").html('中');
                return;
            } else if (jQuery('#mobilepass').val().length < 21) {
                document.getElementById('mobilpass3').className = "p_red";
                jQuery("#mobilpassspan").html('强');
                return;
            }
        } 
        function checkRePass2() {
            if (jQuery('#mobileuserpass2').val() != jQuery('#mobilepass').val()) {
                document.getElementById('mobileuserpassspan').className = "important";
                return;
            } else {
                document.getElementById('mobileuserpassspan').className = "";
            }
        }
        function checkemailReg() {
            if (jQuery('#email').val().length < 3) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('必须输入有效邮箱地址并且不可为空');
                return;
            } else if (jQuery('#email').val() == "请输入邮箱地址") {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('邮箱不能为空');
                return;
            } else if (!EmailValidate(jQuery('#email').val())) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('您输入的邮箱格式错误');
                return;
            } else {
                document.getElementById('Regemail').className = "";
                jQuery("#emailMessage").html('&nbsp;');
            }
        }
        function checkusernameReg() {
            if (jQuery('#username').val() == "") {
                document.getElementById('username').value = "请避免使用真实姓名，注册成功后不可修改";
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else if (jQuery('#username').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else if (jQuery('#username').val().length < 2) {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else {
                document.getElementById('Reusernaem').className = "";
                jQuery("#usernamemeassage").html('&nbsp;');
            }
        }
        function checkPass() {
            if (jQuery('#userpass').val().length < 7) {
                document.getElementById('pass1').className = "p_red";
                jQuery("#qiang").html('弱');
                return;
            } else if (jQuery('#userpass').val().length < 13) {
                document.getElementById('pass2').className = "p_red";
                jQuery("#qiang").html('中');
                return;
            } else if (jQuery('#userpass').val().length < 21) {
                document.getElementById('pass3').className = "p_red";
                jQuery("#qiang").html('强');
                return;
            }
        }
        function checkRePass() {
            if (jQuery('#userpass').val() != jQuery('#userpass2').val()) {
                document.getElementById('Reuserpass2').className = "important";
                return;
            } else {
                document.getElementById('Reuserpass2').className = "";
            }
        }
        function checkFrm() {
            checkemail(jQuery('#email').val());
            checkusername(jQuery('#username').val());
            if (jQuery('#email').val().length < 3) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('必须输入有效邮箱地址');
                return;
            } else if (jQuery('#email').val() == "请输入邮箱地址") {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('邮箱不能为空');
                return;
            } else if (!EmailValidate(jQuery('#email').val())) {
                document.getElementById('Regemail').className = "important";
                jQuery("#emailMessage").html('您输入的邮箱格式错误');
                return;
            } else if (jQuery('#username').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else if (jQuery('#username').val().length < 2) {
                document.getElementById('Reusernaem').className = "important";
                jQuery("#usernamemeassage").html('请输入用户名');
                return;
            } else if (jQuery('#userpass').val().length < 6) {
                alert("请输入密码!");
                return;
            }
            else if (jQuery('#userpass2').val() != jQuery('#userpass').val()) {
                alert("两次密码不一致!");
                return;
            }
            else if (jQuery('#checkcode').val().length < 4 || jQuery('#checkcode').val() == "请输入右边的字符") {
                alert("请输入验证码!");
                return;
            }
            else {
                if (checkemailflag == 0) {
                    alert('此邮箱已经注册过!');
                    return;
                }
                if (checkeusernameflag == 0) {
                    alert('此用户名已经注册过!');
                    return;
                }
                if ($('#checkBox').attr('checked')) {   // do something
                   // jQuery('form').attr("action", "Ajax/MemberLogin.ashx?t=add&checkcode=" + jQuery('#checkcode').val() + "&username=" + jQuery('#username').val() + "&userpass=" + jQuery('#userpass').val() + "&email=" + jQuery('#email').val()).submit();
                    jQuery.ajax({
                        url: "Ajax/MemberLogin.ashx",
                        data: { t: 'add', checkcode: jQuery('#checkcode').val(), username: jQuery('#username').val(), userpass: jQuery('#userpass').val(), email: jQuery('#email').val()},
                        type: "POST",
                        async: false,
                        success: function (data) {
                            if (data + '' != '注册成功！') {
                                alert(data);
                                return false;
                            } else {
                                alert(data);
                                window.parent.location.href = '/personal.aspx';
                                return true;
                            }
                        }
                    });
                } else {
                    alert('您还没查看条款!');
                    return;
                }
            }
        }
        function EmailValidate(value) {
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            return myreg.test(value);
        }
        function validate(value) {
            var reg = new RegExp("^[A-Za-z0-9]+$");
            if (!reg.test(value)) {
                alert("请输入数字和26个英文字母组成的字符串!");
            }
        }
        function checkFrmMobile() {
            checkusername(jQuery('#mobileusername').val()); 
            if (jQuery('#mobileReg').val().length !=11) {
                document.getElementById('mobileRegp').className = "important";
                jQuery("#mobileRegSpan").html('必须输入有效手机号');
                return;
            } else if (jQuery('#checkcodemobile').val().length < 4 || jQuery('#checkcodemobile').val() == "请输入右边的字符") {
                alert("请输入确认码!");
                return;
            } else if (jQuery('#checkcode2').val().length < 4 || jQuery('#checkcode2').val() == "请输入接收到的验证码") {
                alert("请输入验证码!");
                return;
            } else if (jQuery('#mobileusername').val() == "请避免使用真实姓名，注册成功后不可修改") {
                document.getElementById('mobileuserp').className = "important";
                jQuery("#mobileuserspan").html('请输入用户名');
                return;
            } else if (jQuery('#mobileusername').val().length < 2) {
                document.getElementById('mobileuserp').className = "important";
                jQuery("#mobileuserspan").html('请输入用户名');
                return;
            } else if (jQuery('#mobilepass').val().length < 6) {
                alert("请输入密码!");
                return;
            }
            else if (jQuery('#mobilepass').val() != jQuery('#mobileuserpass2').val()) {
                alert("两次密码不一致!");
                return;
            }
            else { 
                if (checkeusernameflag == 0) {
                    alert('此用户名已经注册过!');
                    return;
                }
                if ($('#checkBoxmobile').attr('checked')) {   // do something
                    //jQuery('form').attr("action", "Ajax/MemberLogin.ashx?t=addMobile&checkcode2=" + jQuery('#checkcode2').val()
                    //+ "&mobile=" + jQuery('#mobileReg').val()
                    //+ "&mobileusername=" + jQuery('#mobileusername').val()
                    //+ "&checkcodemobile=" + jQuery('#checkcodemobile').val()
                    //+ "&mobilepass=" + jQuery('#mobilepass').val()).submit();
                    jQuery.ajax({
                        url: "Ajax/MemberLogin.ashx",
                        data: { t: 'addMobile', checkcode2: jQuery('#checkcode2').val(), mobile: jQuery('#mobileReg').val(), mobileusername: jQuery('#mobileusername').val(), checkcodemobile: jQuery('#checkcodemobile').val(), mobilepass: jQuery('#mobilepass').val() },
                        type: "POST",
                        async: false,
                        success: function (data) {
                            if (data + '' != '注册成功！') {
                                alert(data);
                                return false;
                            } else {
                                alert(data);
                                window.parent.location.href = '/personal.aspx';
                                return true;
                            }
                        }
                    });
                } else {
                    alert('您还没查看条款!');
                    return;
                }
            }
        }
        function fresh() {   //点击验证码不刷新页面
            var randomnum = Math.random();
            $("#checkCode_img").attr("src", "/Ajax/vilcode.aspx?" + randomnum);
        }
        function fresh2() {   //点击验证码不刷新页面
            var randomnum = Math.random();
            $("#checkCode_imgmobile").attr("src", "/Ajax/vilcode.aspx?" + randomnum);
        }
        function a() {
            var parten = /^\s*$/;
            if (parten.test($("#mobileuserpass2").val())) {

            }
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="reg_box">
            <h2 class="reg_t"></h2>
        <!--Start-->
        <script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(function(){	
	$('.tabPanel ul li').click(function(){
		$(this).addClass('hit').siblings().removeClass('hit');
		$('.panes>div:eq('+$(this).index()+')').show().siblings().hide();	
	})
})
</script>
<div class="tabPanel">
		<ul>
			<li class="hit">手机号注册</li>
			<li>邮箱注册</li>
		</ul>
		<div class="panes">
			<div class="pane" style="display:block; background:url(../images/tab.jpg)no-repeat 0 0;">
            	<dl class="reg_dl">
                                <dd>
                                    <p class="reg_n">
                                        手机号</p>
                                        <input type="text" class="regbox" maxlength="11"  value="请输入手机号"
                                        name="mobileReg" id="mobileReg" onfocus="this.value=''" onblur="checkmobileReg()" /> 
                                    <p  id="mobileRegp"></p>
                                    <p class="reg_red"> <span id="mobileRegSpan">&nbsp;</span></p>  
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                       确认码</p>
                                    <input type="text" class="regbox2" maxlength="4"  value="请输入右边的字符"
                                        name="checkcodemobile" id="checkcodemobile" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入右边的字符'}" />  
                                    <span class="code">
                                    <a href="javascript:fresh2()"><img src="/Ajax/vilcode.aspx" id="checkCode_imgmobile"  alt="" width="81" height="31"/></a>
                                    </span> 
                                    <p class="p_kb">
                                    </p>
                                </dd> 
                                <dd>
                                    <p class="reg_n">
                                        验证码</p>
                                         <input type="text" class="regbox3" maxlength="4"  value="请输入接收到的验证码"
                                        name="checkcode2" id="checkcode2" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入接收到的验证码'}" />   
                                        <input id="zphone" type="button" class="huoqu" value="点击获取验证码"  onclick="javascript:sendMsgInfo();"/> 
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd> 
                                    <p class="reg_n">用户名</p>
                                    <input type="text" class="regbox" onblur="mobileusernameReg()" onfocus="this.value=''"
                                         name="mobileusername" id="mobileusername" value="请避免使用真实姓名，注册成功后不可修改"/>
                                    <p  id="mobileuserp"></p>
                                    <p class="reg_red"> <span id="mobileuserspan">&nbsp;</span></p>
                                </dd> 
                                <dd> <p class="reg_n">密码</p>
                                    <input   class="regbox"  placeholder="6-20字符，不能为汉字（区分大小写）" onblur="checkmobilePass();"  
                                    name="mobilepass"  id="mobilepass" type="password" maxlength="20"  onkeydown="if(event.keyCode == 32)return false"/>
                                    <p class="reg_password">
                                    <span class="p_n">密码强度</span>
                                    <span class="p_f" id="mobilpass1"></span>
                                    <span class="p_f" id="mobilpass2"></span>
                                    <span class="p_f" id="mobilpass3"></span>
                                    <b class="red_f"><span id="mobilpassspan">&nbsp;</span></b>
                                    </p> 
                                </dd>
    
                                <dd>
                                    <p class="reg_n">确认密码</p>
                                    <input   class="regbox" placeholder="请再次确认你上次输入的密码"  onblur="checkRePass2()" 
                                    name="mobileuserpass2" id="mobileuserpass2" type="password"  onkeydown="if(event.keyCode == 32)return false"/> 
                                    <p id="mobileuserpassspan"></p>
                                    <p class="p_kb"></p>
                                </dd> 
                                <dd>
                                    <input type="button" onclick="javascript:checkFrmMobile();" class="regbtn" value="立即注册"/>  
                                    <a href="login.aspx" class="reg_a">已有账号？</a> <a href="login.aspx" class="reg_b">立即登录</a>
                                </dd>
                                <dd>
                                    <p class="reg_agree">
                                        <input type="checkbox" checked="checked" id="checkBoxmobile" />
                                        我已同意<a href="/about.aspx?id=19" class="reg_c" target="_blank">《彩票米米用户服务条款》</a>
                                    </p>
                                </dd>
                            </dl>
            </div>
			<div class="pane">
            	 <dl class="reg_dl">
                                <dd>
                                    <p class="reg_n">邮箱</p>
                                    <input type="text" class="regbox" maxlength="30"  value="请输入邮箱地址"
                                        name="email" id="email" onfocus="this.value=''"
                                        onblur="checkemailReg()" /> 
                                    <p  id="Regemail"></p>
                                    <p class="reg_red"> <span id="emailMessage">&nbsp;</span></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">用户名</p>
                                    <input type="text" class="regbox" onblur="checkusernameReg()" onfocus="this.value=''"
                                         name="username" id="username" value="请避免使用真实姓名，注册成功后不可修改"/>
                                    <p  id="Reusernaem"></p>
                                    <p class="reg_red"> <span id="usernamemeassage">&nbsp;</span></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">密码</p>
                                    <input   class="regbox"  placeholder="6-20字符，不能为汉字（区分大小写）" onblur="checkPass();"  
                                    name="userpass"  id="userpass" type="password" maxlength="20" onkeydown="if(event.keyCode == 32)return false"/>
                                    <p class="reg_password">
                                    <span class="p_n">密码强度</span>
                                    <span class="p_f" id="pass1"></span>
                                    <span class="p_f" id="pass2"></span>
                                    <span class="p_f" id="pass3"></span>
                                    <b class="red_f"><span id="qiang">&nbsp;</span></b>
                                    </p>
                                </dd>
                                <dd>
                                    <p class="reg_n">确认密码</p>
                                    <input   class="regbox" placeholder="请再次确认你上次输入的密码"  onblur="checkRePass()" 
                                    name="userpass2" id="userpass2" type="password" onkeydown="if(event.keyCode == 32)return false"/> 
                                    <p id="Reuserpass2"></p>
                                    <p class="p_kb"></p>
                                </dd>
                                <dd>
                                    <p class="reg_n">
                                        验证码</p>
                                    <input type="text" class="regbox2" maxlength="4"  value="请输入右边的字符"
                                        name="checkcode" id="checkcode" onfocus="this.value=''"
                                        onblur="if(this.value==''){this.value='请输入右边的字符'}" />  
                                    <span class="code">
                                    <a href="javascript:fresh()"><img src="/Ajax/vilcode.aspx" id="checkCode_img"  alt="" width="81" height="31"/></a>
                                    </span> 
                                    <p class="p_kb">
                                    </p>
                                </dd>
                                <dd> 
                                    <input type="button" onclick="javascript:checkFrm();" class="regbtn" value="立即注册"/> 
                                    <a href="login.aspx" class="reg_a">已有账号？</a> <a href="login.aspx" class="reg_b">立即登录</a>
                                </dd>
                                <dd>
                                    <p class="reg_agree">
                                        <input type="checkbox" checked="checked" id="checkBox" />我已同意<a href="/about.aspx?id=19" target="_blank" class="reg_c">《彩票米米用户服务条款》</a>
                                    </p>
                                </dd>
                            </dl>
            </div>
		</div>
    </div>
</div>
       <!--End-->

    </div>
    <script language="javascript" type="text/javascript">
        var speed = 121000; //转换速度 (1000 = 1 秒) 
        function sendMsgInfo() {
            if (jQuery('#mobileReg').val().length < 11) {
                alert("请输入正确的手机号码!");
                return;
            }
            else {
                $.post("/Ajax/SubmitMsg.aspx", { mobileNum: jQuery('#mobileReg').val(), Type: 1, ck_thecode: jQuery('#checkcodemobile').val() }, function (data) {
                    var str = eval(data);
                 
                    if (str[1].value.toString() == "OK") {

                        alert("发送成功!");
                      
                       // alert("发送成功!");
                    } else {
                        alert(data);
                        document.getElementById("checkCode_imgmobile").src = "/Ajax/vilcode.aspx";
                    }
                }, "text");
            }
            RemainTime();
        }
        var iTime = 59;
        var Account;
        function RemainTime() {
            var iSecond, sSecond = "", sTime = "";
            document.getElementById('zphone').disabled = true;
            if (iTime >= 0) {
                iSecond = parseInt(iTime % 60);
                iMinute = parseInt(iTime / 60)
                if (iSecond >= 0) {
                    if (iMinute > 0) {
                        sSecond = iMinute + "分" + iSecond + "秒";
                    } else {
                        sSecond = iSecond + "秒后重新获取";
                    }
                }
                sTime = sSecond;
                if (iTime == 0) {
                    clearTimeout(Account);
                    sTime = '获取手机验证码';
                    iTime = 59;
                    document.getElementById('zphone').disabled = false;
                } else {
                    Account = setTimeout("RemainTime()", 1000);
                    iTime = iTime - 1;
                }
            } else {
                sTime = '没有倒计时';
            }
            document.getElementById('zphone').value = sTime;
        }
</script>
    </form>
</body>
</html>
